//
//  ClassCommunitySupermarketViewController.m
//  CommunitySupermarketProiect
//
//  Created by 吕惠卿 on 2017/11/13.
//  Copyright © 2017年 吕惠卿. All rights reserved.
//

#import "ClassCommunitySupermarketViewController.h"
#import "SegmentViewController.h"
#import "ExampleViewController.h"
static CGFloat const ButtonHeight = 50;

@interface ClassCommunitySupermarketViewController ()

@end

@implementation ClassCommunitySupermarketViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    WhiteColor;
    NAVIGATIONTITLE(@"产品分类");
    [self creatUI];
    [self creatNavigationItem];
}

-(void)creatUI{
    SegmentViewController *vc = [[SegmentViewController alloc]init];
    NSArray *titleArray = @[@"生活用品", @"厨房用品", @"小吃零食"];
    
    vc.titleArray = titleArray;
    NSMutableArray *controlArray = [[NSMutableArray alloc]init];
    for (int i = 0; i < vc.titleArray.count; i ++) {
        ExampleViewController *vc = [[ExampleViewController alloc]initWithIndex:i title:titleArray[i]];
        [controlArray addObject:vc];
    }
    vc.titleSelectedColor = NavColor;
    vc.subViewControllers = controlArray;
    vc.buttonWidth = 90;
    vc.buttonHeight = ButtonHeight;
    [vc initSegment];
    [vc addParentController:self];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
-(void)creatNavigationItem{
    UIButton *btn = [UIButton new];
    [btn setImage:[UIImage imageNamed:@"返回"] forState:UIControlStateNormal];
    [btn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
    [btn sizeToFit];
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:btn];
    
    UIButton *btnright = [UIButton new];
    [btnright setImage:[UIImage imageNamed:@"产品列表搜索"] forState:UIControlStateNormal];
    [btnright addTarget:self action:@selector(seachClick) forControlEvents:UIControlEventTouchUpInside];
    [btnright sizeToFit];
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:btnright];
}
-(void)seachClick{
    
}
- (void)btnClick:(id)sender {
    [self.navigationController popViewControllerAnimated:YES];
}

@end
